package com.jsoft.android.exp.ffxiii;

import android.app.ListActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.TextView;

public class CharactersPicker  extends ListActivity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        //setContentView(R.layout.main);

        //setListAdapter(new ArrayAdapter<String>(this, R.layout.list_item, CHARACTERS));
        String[] characters = getResources().getStringArray(R.array.characters_array);
        setListAdapter(new ArrayAdapter<String>(this, R.layout.list_item, characters));

        ListView lv = getListView();

        lv.setOnItemClickListener(new OnItemClickListener() {
          @Override
		public void onItemClick(AdapterView<?> parent, View view,
              int position, long id) {
            // When clicked send the TextView text
           
            Bundle bundle = new Bundle();
            bundle.putCharSequence(Exp.KEY_TITLE, ((TextView) view).getText());
            
            Intent mIntent = new Intent();
            mIntent.putExtras(bundle);
            setResult(RESULT_OK, mIntent);
            //setResult(RESULT_OK);
            finish();
            
          }
        });
    }
    
    /*static final String[] CHARACTERS = new String[] {
        "Lightning", "Sazh", "Snow", "Hope","Vanelle", "Fang"
    };
         */

}